#include<stack>
#include<string>
#include<iostream>
#include<vector>
using namespace std;


class Solution {
public:
    int calculate(string s)
    {
        vector<int> stack;
        int i = 0, n = s.size();
        char op = '+';
        while (i < n)
        {
            if (s[i] == ' ') ++i;
            else if (s[i] >= '0' && s[i] <= '9')
            {
                int tmp = 0;
                while (i < n && s[i] >= '0' && s[i] <= '9')
                    tmp = tmp * 10 + (s[i++] - '0');
                if (op == '+') stack.push_back(tmp);
                else if (op == '-') stack.push_back(-tmp);
                else if (op == '*') stack.back() *= tmp;
                else stack.back() /= tmp;
            }
            else
            {
                op = s[i++];
            }
        }
        int ret = 0;
        for (auto ch : stack)
            ret += ch;
        return ret;
    }
};

int main()
{
    Solution s1;
    string s = "43+2/7+33333111111111111111";
    int b = s1.calculate(s);
    cout << b << endl;
    return 0;
}